<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!DOCTYPE p PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<fmt:setBundle basename="bundles.railroadOrderBundle" />

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="layout/jsc/changerowcolor.js"></script>
<script type="text/javascript" src="layout/jsc/rowclick.js"></script>

</head>

<body>

<H1 align="center"><fmt:message key="station.messege"></fmt:message></H1>

<c:set var="stations" value="${sessionScope['stations'] }"></c:set>
<c:set var="id_route" value="${sessionScope['id_route'] }"></c:set>

<c:if test="${not empty stations}">
	<table id="route_table" width="50%" border="1" cellpadding="0"
		align="center" cellspacing="0">
		<thead>
			<tr>
				<th><fmt:message key="station.number"></fmt:message></th>
				<th><fmt:message key="station.name"></fmt:message></th>
				<th><fmt:message key="station.altitude"></fmt:message></th>
				<th><fmt:message key="station.longitude"></fmt:message></th>
			</tr>
		</thead>

		<tbody>
			<c:forEach var="station" items="${stations}" varStatus="rowCounter">
				<tr onmouseover="ChangeColor(this, true);"
					onmouseout="ChangeColor(this, false);"
					onclick="onClick(${rowCounter.count}, 0, station_edit, station_edit.id_station)">
					<td><c:out value="${station.station_id}" /></td>
					<td><c:out value="${station.stationName}" /></td>
					<td><c:out value="${station.altitude}" /></td>
					<td><c:out value="${station.longitude}" /></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</c:if>

<c:set var="admin" value="${sessionScope['admin'] }"></c:set>
<c:set var="routes" value="${sessionScope['buy'] }"></c:set>


<table align="center">

	<tr>
		<c:if test="${buy}">
			<td>
			<form method="POST" action="/pages/order_ticket.do"><input
				type="hidden" name="id_route" value="${id_route}">
			<button type="submit"><fmt:message key="order.make"></fmt:message></button>
			</form>
			</td>
		</c:if>

		<c:if test="${not buy}">
			<td align="center"><fmt:message key="route.buy"></fmt:message></td>
		</c:if>

	</tr>

	<c:if test="${not empty admin }">
		<tr>
			<td>
			<form id="route_remove" method="get" action="/pages/route_remove.do">
			<input type="hidden" name="id_route" value="${id_route}">
			<button type="submit""><fmt:message key="route.remove"></fmt:message></button>
			</form>
			
			<form id="route_edit" method="get" action="/pages/route_edit.jsp">
			<input type="hidden" name="id_route" value="${id_route}">
			<button type="submit""><fmt:message key="route.edit"></fmt:message></button>
			</form>
			
			</td>
			<td>
			<form id="station_add" method="get"
				action="/pages/station_insert.jsp">
			<table align="center">
				<tbody>
					<tr>
						<td><input type="hidden" name="id_route" value="${id_route}">
						</td>
						<td>
						<button type="submit"><fmt:message key="station.add"></fmt:message></button>
						</td>
					</tr>
				</tbody>
			</table>
			</form>
			</td>
		</tr>
		<form id="station_edit" method="get" action="/pages/station_edit.do">
		<input type="hidden" name="id_route" value="${id_route}"> <input
			type="hidden" name="id_station" value="-1"></form>
	</c:if>
</table>

</body>

</html>